fetcher: Return NOT_FOUND when the HTTP code is 410 or 404
authorVivek Dasmohapatra <vivek@collabora.co.uk>
Mon, 19 Aug 2013 17:13:44 +0000 (18:13 +0100)
committerColin Walters <walters@verbum.org>
Fri, 23 Aug 2013 16:15:49 +0000 (12:15 -0400)
This will be used by the pull code to download optional data.

src/libostree/ostree-fetcher.c

index e1f3db2aea20c6e468903ce81b1f153bbf7d15cf..b9af77c52d360426f8c853d5cec862ef23a63d45 100644 (file)
@@ -214,7 +214,17 @@ on_request_sent (GObject        *object,
       msg = soup_request_http_get_message ((SoupRequestHTTP*) object);
       if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
         {
-          g_set_error (&local_error, G_IO_ERROR, G_IO_ERROR_FAILED,
+          GIOErrorEnum code;
+          switch (msg->status_code)
+            {
+            case 404:
+            case 410:
+              code = G_IO_ERROR_NOT_FOUND;
+              break;
+            default:
+              code = G_IO_ERROR_FAILED;
+            }
+          g_set_error (&local_error, G_IO_ERROR, code,
                        "Server returned status %u: %s",
                        msg->status_code, soup_status_get_phrase (msg->status_code));
           g_simple_async_result_take_error (pending->result, local_error);